﻿using B.S.BasicData.Domain;
using B.S.BasicData.ErrorCode;
using B.S.BasicData.Read.Apilication.Common.Menu;
using B.S.BasicData.Read.DTOS;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.S.BasicData.Read.Controllers
{
    /// <summary>
    /// Api 控制器-菜单管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class MenuController : ControllerBase
    {
        private readonly IMediator mediator;

        public MenuController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 菜单名称查询
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<MenuDto>>> MeunShow([FromQuery ]MenuNameCommand command)
        { 
            return mediator.Send(command);
        }

        /// <summary>
        /// 菜单列表显示
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiPaimg<MenuNameDto>> MenuAll([FromQuery] MenuShowCommand command)
        {
            return mediator.Send(command);
        }

        /// <summary>
        /// 查询是否存在子集
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<MenuModel>>> GetmenuParmentHandle([FromQuery] GetOneCommand command)
        {
            return mediator.Send(command);
        }

    }
}
